/**
* log 打印工具，静态调用
* Author: dong xing
* Date: 2019-01-29
* Time: 15:29
* Email: dong.xing@outlook.com
*/

export default class Log {
  /**
   * 返回类型的颜色值
   * @param type
   * @returns {string}
   */
  static typeColor (type) {
    let color = ''
    switch (type) {
      case 'default': color = '#35495E'; break
      case 'primary': color = '#3488ff'; break
      case 'success': color = '#43B883'; break
      case 'warning': color = '#e6a23c'; break
      case 'danger': color = '#f56c6c'; break
      default:; break
    }
    return color
  }

  // 打印赋予颜色的内容
  static capsule (title, message, type) {
    console.log(
      `%c ${title} %c ${message} %c`,
      'background:#757575; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;',
      `background:${this.typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0;  color: #fff;`,
      'background:transparent'
    )
  }

  // 打印 default 颜色的信息
  static default (title, message) {
    this.capsule(title, message, 'default')
  }

  // 打印 primary 颜色的信息
  static primary (title, message) {
    this.capsule(title, message, 'primary')
  }

  // 打印 success 颜色的信息
  static success (title, message) {
    this.capsule(title, message, 'success')
  }

  // 打印 warning 颜色的信息
  static warning (title, message) {
    this.capsule(title, message, 'warning')
  }

  // 打印 danger 颜色的信息
  static danger (title, message) {
    this.capsule(title, message, 'danger')
  }
}
